app = angular.module('myApp', []);

app.controller('myCtrl', function($scope, $http) {

	var bola = true;

	$('.w-register-input4 p').click(function() {

		if(bola) {
			$('.w-register-input4 p img').attr('src', '../img/jifendingdan/circle1.png');
			bola = !bola;
			$('.w-register-divdiv').css({
				'display': 'none',
			})
		} else {
			$('.w-register-input4 p img').attr('src', '../img/jifendingdan/circle0.png');
			bola = !bola;
			$('.w-register-divdiv').css({
				'display': 'block',
			})
		}

	})
	//当手机号密码都符合时注册颜色变成红色

	console.log($('.btnbtnbtn'))
	$('.btnbtnbtn').click(function() {
		
		console.log(11111);

		var inputone = document.getElementById('in1');
		var inputfour = document.getElementById('in3');
		var inputtwo = document.getElementById('in2');
		console.log(inputone.value, inputfour.value);
			//localstorage
		localStorage.tel= inputone.value;
		//开始用ajax向后台php传数据;
		if(window.XMLHttpRequest) {
			var ajax = new XMLHttpRequest();
		} else {
			var ajax = new ActiveXObject('Microsoft.XMLHTTP');
		}
		ajax.onreadystatechange = function() {
			if(this.readyState == 4 && this.status == 200) {
				
			}
		};

		ajax.open('GET', '../php/user.php?phone=' + inputone.value + '&mima=' + inputfour.value);
		ajax.send();

		var aaaa = document.querySelector('.form');
		aaaa.reset();
		//此时应该把所有按钮重置
	
		window.location.href = 'main.html';
		return false;
	})

	$scope.enterbol = true;
	$scope.enterboltwo = false;
	$('#enterButton').click(function() {

		var enterInput = document.getElementById('in1');
		var entermima = document.getElementById('in2');

		console.log(enterInput.value);
		$http.get('../php/enter.php?enterInput=' + enterInput.value).success(function(data) {
			$scope.mima = data;
			$scope.entermima = $scope.mima[0].mima;
			console.log(data);
			console.log($scope.entermima);
			if($scope.entermima == entermima.value) {
				$scope.enterbol = true;
				$scope.enterboltwo = true;
			} else {
				$scope.enterbol = false;
				$scope.enterboltwo = false;
			}
		})
	})
	var checkboxbol = true;
	$('.auto-enter span').eq(0).click(function() {
		if(checkboxbol) {
			$('.auto-enterimg').attr({
				'src': '../img/login/checkbox2.png'
			});
			checkboxbol = !checkboxbol;
		}else{
			$('.auto-enterimg').attr({
				'src': '../img/login/checkbox1.png'
			});
			checkboxbol = !checkboxbol;
		}

	})

})